#!/usr/bin/env bash

echo > add-work-node.sh
echo > k8s-init.log

scp master0:/tmp/k8s-init.log  . 

grep -A 5 "worker nodes"  k8s-init.log  | grep -A 5 "kubeadm" | tail -n 2  > add-work-node.sh

if grep -q "kubeadm join"  add-work-node.sh
then 
   echo "generate kubeadm join command , it is ok!"
else
   echo "failed to generate add-work-node.sh" 
fi 

chmod a+x add-work-node.sh
echo "cat add-work-node.sh:" 

cat add-work-node.sh

